package comp4081.java.hibernate;


/*import java.sql.Date;
import java.util.List;*/
import java.util.*;

/*import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;*/
import javax.persistence.*;

import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.annotations.*;
import org.hibernate.tool.hbm2ddl.*;


@Entity
@Table (name="PATIENT2", schema="test")
public class Patient2{
	private Long id;
	private String firstName;
	private String lastName;
	private List<Diagnose2> diagnoses2;
	
	@OneToMany(mappedBy="patient2", targetEntity=Diagnose2.class, 
			fetch=FetchType.EAGER, cascade= CascadeType.ALL)
	public List<Diagnose2> getDiagnoses(){return diagnoses2;}
	public void setDiagnoses(List<Diagnose2> diagnoses2){this.diagnoses2=diagnoses2;}
	
	@Id
	@GeneratedValue
	@Column (name="ID")
	public Long getId(){
		return id;
	}
	public void setId(Long id){
		this.id = id;
	}
	@Column (name="FIRST_NAME")
	public String getFirstName(){
		return firstName;
	}
	
	@Column (name="FIRST_NAME")
	public void setFirstName(String firstName){
		this.firstName = firstName;
	}
	
	@Column (name="LAST_NAME")
	public String getLastName(){
		return lastName;
	}
	
	@Column (name="LAST_NAME")
	public void setLastName(String lastName){
		this.lastName = lastName;
	}

	
	
	public static void main(String[] args){
		//create a configuration object, reading from the hibernate.cf.xml file
		//Configuration config = new Configuration();
		Configuration config = new Configuration();
		//make sure hibernate aware of the User class
		config.addAnnotatedClass(Patient2.class);
		//read and process hibernate.cfg.xml and JPA metadata
		config.configure();
		new SchemaExport(config).create(true,true);
	    
	}
}